package com.collection;

import java.util.TreeMap;

/**
 * @ClassName TreeMapTest
 * @Date 2021/5/16 19:46
 * @Author 李明杰
 * @Description 结论：插入到 TreeMap、TreeSet的数据，自动排序
 */

public class TreeMapTest {
    public static void main(String[] agrs) {
        //自然顺序比较
        naturalSort();
    }

    //自然排序顺序：
    public static void naturalSort() {
        //第一种情况：Integer对象
        TreeMap<Integer, String> treeMapFirst = new TreeMap<Integer, String>();
        treeMapFirst.put(1, "huangqiuping");
        treeMapFirst.put(6, "huangqiuping");
        treeMapFirst.put(3, "huangqiuping");
        treeMapFirst.put(10, "huangqiuping");
        treeMapFirst.put(7, "huangqiuping");
        treeMapFirst.put(13, "huangqiuping");
        System.out.println(treeMapFirst.toString());
    }
}
